/* ck Search Panel - Crisp, Terminal-inspired */

:root {
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;

  /* Score colors - Green to red gradient (1.0 → 0.0) */
  --score-excellent: #4ec991; /* Green */
  --score-good: #a9d96c; /* Yellow-green */
  --score-fair: #e8a858; /* Orange */
  --score-poor: #e85b5b; /* Red */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--vscode-foreground);
  background-color: var(--vscode-sideBar-background);
  overflow: hidden;
}

.search-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header - Compact and clean */
.search-header {
  padding: 6px var(--spacing-sm);
  border-bottom: 1px solid var(--vscode-panel-border);
  background-color: var(--vscode-sideBar-background);
}

.search-input-wrapper {
  margin-bottom: 6px;
}

#searchInput {
  width: 100%;
  padding: 4px var(--spacing-sm);
  font-family: var(--vscode-font-family);
  font-size: 12px;
  color: var(--vscode-input-foreground);
  background-color: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.1s;
}

#searchInput:focus {
  border-color: var(--vscode-focusBorder);
  box-shadow: 0 0 0 1px var(--vscode-focusBorder);
}

.search-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 6px;
}

#modeSelector {
  flex: 1;
  padding: 3px 6px;
  font-family: var(--vscode-font-family);
  font-size: 11px;
  font-weight: 400;
  color: var(--vscode-foreground);
  background-color: var(--vscode-dropdown-background);
  border: 1px solid var(--vscode-dropdown-border);
  border-radius: 2px;
  cursor: pointer;
}

#reindexButton {
  padding: 4px var(--spacing-sm);
  background-color: var(--vscode-button-secondaryBackground);
  color: var(--vscode-button-secondaryForeground);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.1s;
}

#reindexButton:hover {
  background-color: var(--vscode-button-secondaryHoverBackground);
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
}

.filter-input {
  width: 100%;
  padding: 3px 6px;
  font-family: var(--vscode-font-family);
  font-size: 11px;
  color: var(--vscode-input-foreground);
  background-color: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.1s;
}

.filter-input:focus {
  border-color: var(--vscode-focusBorder);
  box-shadow: 0 0 0 1px var(--vscode-focusBorder);
}

.filter-input::placeholder {
  color: var(--vscode-input-placeholderForeground);
  opacity: 0.6;
}

.index-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.index-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--vscode-descriptionForeground);
  flex: 1;
  min-width: 0;
}

.index-status .status-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.index-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background-color: transparent;
  color: var(--vscode-button-secondaryForeground);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--vscode-focusBorder);
}

.link-button {
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--vscode-textLink-foreground);
  cursor: pointer;
  font-size: 10px;
  line-height: 1.6;
}

.link-button:hover {
  border-color: var(--vscode-textLink-foreground);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--vscode-charts-gray);
}

.status-indicator.healthy {
  background-color: var(--vscode-charts-green);
}

.status-indicator.warning {
  background-color: var(--vscode-charts-yellow);
}

.index-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--vscode-descriptionForeground);
  padding: 4px 6px;
  border: 1px solid var(--vscode-panel-border);
  border-radius: 4px;
  background-color: var(--vscode-sideBarSectionHeader-background);
}

.index-progress.hidden {
  display: none;
}

.index-progress .codicon {
  animation: spin 1s linear infinite;
}

/* Body */
.search-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  gap: var(--spacing-sm);
  color: var(--vscode-descriptionForeground);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--vscode-progressBar-background);
  border-top-color: var(--vscode-foreground);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.results-container {
  padding: var(--spacing-xs);
}

.empty-state {
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--vscode-descriptionForeground);
}

.empty-state p {
  margin: var(--spacing-sm) 0;
}

.empty-state .hint {
  font-size: 10px;
  font-style: italic;
  opacity: 0.7;
}

/* Toolbar */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  padding: 4px var(--spacing-sm);
  background-color: var(--vscode-sideBar-background);
  border: 1px solid var(--vscode-widget-border);
  border-radius: 4px;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vscode-descriptionForeground);
}

.toolbar-buttons {
  display: flex;
  gap: 6px;
}

.toolbar-button {
  padding: 3px 10px;
  border: 1px solid var(--vscode-toolbar-hoverOutline, transparent);
  border-radius: 3px;
  background-color: var(--vscode-button-secondaryBackground);
  color: var(--vscode-button-secondaryForeground);
  font-family: var(--vscode-font-family);
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

.toolbar-button:hover {
  background-color: var(--vscode-button-secondaryHoverBackground);
}

.toolbar-button:focus {
  outline: none;
  border-color: var(--vscode-focusBorder);
  box-shadow: 0 0 0 1px var(--vscode-focusBorder);
}

.file-group-stack {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.file-group-stack .file-group {
  margin-bottom: 0;
}

.near-matches-header {
  margin: var(--spacing-sm) 0 var(--spacing-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--vscode-descriptionForeground);
  padding-left: 2px;
}

/* File Groups - Collapsible sections */
.file-group {
  margin-bottom: var(--spacing-sm);
  border: 1px solid var(--vscode-widget-border);
  border-radius: 3px;
  overflow: hidden;
  background-color: var(--vscode-editor-background);
}

.file-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background-color: var(--vscode-sideBar-background);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--vscode-widget-border);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.1s;
}

.file-group-header:hover {
  background-color: var(--vscode-list-hoverBackground);
}

.toggle-icon {
  font-size: 9px;
  color: var(--vscode-descriptionForeground);
  width: 12px;
  display: inline-block;
  transition: transform 0.1s ease;
}

.file-group.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.file-group-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.file-group-name {
  flex: 1;
  color: var(--vscode-textLink-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-group-basename {
  font-weight: 600;
  color: var(--vscode-textLink-foreground);
  white-space: nowrap;
}

.file-group-subpath {
  color: var(--vscode-descriptionForeground);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-group-metrics {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background-color: var(--vscode-badge-background);
  color: var(--vscode-badge-foreground);
  min-width: 20px;
}

.metric-pill--count {
  letter-spacing: 0.02em;
}

.metric-pill--score {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--vscode-descriptionForeground);
}

.file-group-results {
  background-color: var(--vscode-editor-background);
  transition: max-height 0.2s ease-out, opacity 0.2s;
}

.file-group.collapsed .file-group-results {
  display: none;
}

.file-group--secondary {
  border-color: rgba(255, 214, 102, 0.35);
  background-color: rgba(255, 214, 102, 0.05);
  opacity: 0.92;
}

.file-group--secondary .file-group-header {
  background-color: rgba(255, 214, 102, 0.08);
}

/* Result Items - Crisp and clean */
.result-item {
  margin-bottom: 1px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.1s;
}

.result-item:hover {
  background-color: var(--vscode-list-hoverBackground);
  border-left-color: var(--vscode-textLink-foreground);
}

.result-item.selected {
  background-color: var(--vscode-list-activeSelectionBackground);
  border-left-color: var(--vscode-focusBorder);
}

.result-item--secondary {
  opacity: 0.7;
}

.result-item--secondary:hover,
.result-item--secondary.selected {
  opacity: 1;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  font-size: 11px;
  border-bottom: 1px solid var(--vscode-widget-border);
  background-color: var(--vscode-editor-background);
  margin-bottom: 1px;
}

.result-file {
  color: var(--vscode-textLink-foreground);
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-location {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--vscode-descriptionForeground);
  font-size: 10px;
}

.result-line {
  font-family: var(--font-mono);
}

.result-score-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  transition: opacity 0.1s ease;
}

.score-label-excellent {
  background-color: rgba(78, 201, 145, 0.18);
  color: var(--score-excellent);
}

.score-label-good {
  background-color: rgba(169, 217, 108, 0.2);
  color: var(--score-good);
}

.score-label-fair {
  background-color: rgba(232, 168, 88, 0.18);
  color: var(--score-fair);
}

.score-label-poor {
  background-color: rgba(232, 91, 91, 0.18);
  color: var(--score-poor);
}

/* Preview - Syntax highlighted with line numbers */
.result-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--vscode-editor-foreground);
  background-color: var(--vscode-editor-background);
  border-top: 1px solid var(--vscode-widget-border);
  border-bottom: 1px solid var(--vscode-widget-border);
  border-radius: 0 0 3px 3px;
  overflow: hidden;
}

.preview-line {
  display: flex;
  padding: 0 6px;
  padding-left: 10px;
  white-space: pre;
  font-variant-ligatures: none;
  tab-size: 4;
  border-top: 1px solid transparent;
  cursor: pointer;
}

.preview-line + .preview-line {
  border-top-color: rgba(128, 128, 128, 0.15);
}

.preview-line:hover {
  background-color: var(--vscode-list-hoverBackground);
}

.preview-line.match-line {
  background-color: var(--vscode-list-activeSelectionBackground);
  color: var(--vscode-list-activeSelectionForeground);
  font-weight: 600;
}

.preview-line.match-line .line-number {
  color: var(--vscode-list-activeSelectionForeground);
  opacity: 0.7;
  font-weight: 600;
}

.line-number {
  display: inline-block;
  min-width: 32px;
  padding-right: var(--spacing-sm);
  text-align: right;
  color: var(--vscode-editorLineNumber-foreground);
  user-select: none;
  opacity: 0.5;
}

.line-content {
  flex: 1;
  overflow-x: auto;
  white-space: pre;
  font-variant-ligatures: none;
  tab-size: 4;
  word-break: normal;
  overflow-wrap: normal;
}

.match-highlight {
  background-color: var(--vscode-editor-findMatchHighlightBackground, rgba(255, 216, 102, 0.45));
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.line-content::-webkit-scrollbar {
  height: 4px;
}

.line-content::-webkit-scrollbar-thumb {
  background: var(--vscode-scrollbarSlider-background);
  border-radius: 2px;
}

/* Syntax highlighting hints */
.token.keyword { color: var(--vscode-symbolIcon-keywordForeground, #569cd6); }
.token.string { color: var(--vscode-symbolIcon-stringForeground, #ce9178); }
.token.comment { color: var(--vscode-symbolIcon-keywordForeground, #6a9955); opacity: 0.75; }
.token.number { color: var(--vscode-symbolIcon-numberForeground, #b5cea8); }
.token.function { color: var(--vscode-symbolIcon-functionForeground, #dcdcaa); }
.token.operator { color: var(--vscode-symbolIcon-operatorForeground, #d4d4d4); }

.error-container {
  padding: var(--spacing-md);
  margin: var(--spacing-md);
  background-color: var(--vscode-inputValidation-errorBackground);
  border: 1px solid var(--vscode-inputValidation-errorBorder);
  border-radius: 3px;
  color: var(--vscode-errorForeground);
  font-size: 11px;
}

.error-container.hidden {
  display: none;
}

/* Footer - Compact */
.search-footer {
  padding: 4px var(--spacing-sm);
  border-top: 1px solid var(--vscode-panel-border);
  background-color: var(--vscode-sideBar-background);
  font-size: 10px;
  color: var(--vscode-descriptionForeground);
  font-family: var(--font-mono);
}

.result-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.count-text {
  font-weight: 500;
}

.rerank-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  background-color: var(--vscode-badge-background);
  color: var(--vscode-badge-foreground);
  border-radius: 2px;
  font-size: 9px;
  font-weight: 600;
}

/* Scrollbar */
.search-body::-webkit-scrollbar {
  width: 8px;
}

.search-body::-webkit-scrollbar-track {
  background: transparent;
}

.search-body::-webkit-scrollbar-thumb {
  background: var(--vscode-scrollbarSlider-background);
  border-radius: 4px;
}

.search-body::-webkit-scrollbar-thumb:hover {
  background: var(--vscode-scrollbarSlider-hoverBackground);
}
